package com.crb.crm.manage.excel.listener;

import com.crb.crm.manage.excel.ExcelTemplate;
import com.crb.crm.manage.excel.model.ShopModel;
import com.crb.crm.manage.pojo.biz.Shop;
import com.crb.crm.manage.service.biz.ShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * Package: com.crb.crm.manage.excel
 * Description：
 * Author: huangjian
 * Date:  2020/9/4 17:07
 * Modified By:
 *
 * @author huangjian
 */
@Slf4j
@Component
class ShopExcelListener extends BaseExcelListener<ShopModel> {

    @Resource
    private ShopService shopService;


    @Override
    protected void validData(ShopModel shopModel, ValidResult validResult) {
    }

    @Override
    public void saveData(List<ShopModel> list) {
        list.forEach(shopModel -> {
            Shop shop = new Shop();
            shop.setName(shopModel.getName());
            shop.setMobile(shopModel.getMobile());
            shopService.setShop(shop);
        });
    }

    @Override
    public ExcelTemplate support() {
        return ExcelTemplate.SHOP;
    }
}
